<template>
    <el-sub-menu :key="data.label" :index="data.label">
        <template #title>
            <span>{{ data.label }}</span>
        </template>
        <template v-for="item in data.children">
            <el-menu-item :key="item.path" :index="item.path" @click="menuSelect(item)"
                v-if="!item.children || item.children?.length === 0">
                <span>{{ item.label }}</span>
            </el-menu-item>
            <mySubMenu v-else :data="item"></mySubMenu>
        </template>
    </el-sub-menu>
</template>

<script setup>
import bus from '@/utils/mitt.js'
import { onBeforeUnmount, onMounted } from 'vue';
const prop = defineProps({
    data: {
        type: Object,
        default: {}
    },
})
// const emit = defineEmits(['menuSelect'])
onMounted(() => {

})
const menuSelect = (item) => {
    bus.emit('menuSelect', item)
}

</script>
